package com.hxkj.controller;

import com.hxkj.domain.po.AdvertisementColumn;
import com.hxkj.domain.po.AdvertisementColumnTree;
import com.hxkj.service.AdvertisementColumnService;
import com.platform.common.domain.result.ResultDataStruct;
import com.platform.common.domain.result.ResultMessageStruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

/**
 * @ClassName ColumnController
 * @Description
 * @Author chenfangzhou
 * @Date 2018/9/9 11:57
 * @Version 1.0
 */
@RestController
@RequestMapping("/advertisementColumn")
public class AdvertisementColumnController {
    private static final Logger LOGGER = LoggerFactory.getLogger(AdvertisementColumnController.class);

    @Autowired
    private AdvertisementColumnService advertisementColumnService;

    /**
     * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultMessageStruct>
     * @author chenfangzhou
     * @Description saveColumn 新增分类
     * @Date 15:22 2018/9/9
     * @Param [column]
     **/
    @RequestMapping(value = "/save", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<ResultDataStruct> saveColumn(@RequestBody AdvertisementColumn column) throws Exception {
        return () -> advertisementColumnService.saveColumn(column);
    }


    /**
     * @return java.util.concurrent.Callable<java.util.List   <   com.hxkj.domain.po.AdvertisementColumnTree>>
     * @author chenfangzhou
     * @Description getColumnTreeList 获取分类的树结构列表
     * @Date 15:53 2018/9/9
     * @Param [column]
     **/
    @RequestMapping(value = "/getlisttree", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<List<AdvertisementColumnTree>> getColumnTreeList(@RequestBody AdvertisementColumn column) throws Exception {
        return () -> advertisementColumnService.getColumnTreeList(column);
    }

    /**
     * @return com.platform.common.domain.result.ResultMessageStruct
     * @author chenfangzhou
     * @Description removerColumn 删除分类
     * @Date 15:20 2018/9/9
     * @Param [column]
     **/
    @RequestMapping(value = "/remove", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<ResultMessageStruct> removeColumn(@RequestBody AdvertisementColumn column) throws Exception {
        return () -> advertisementColumnService.removeColumn(column);
    }

    /**
     * @return com.platform.common.domain.result.ResultMessageStruct
     * @author chenfangzhou
     * @Description modifyColumn 修改分类
     * @Date 15:22 2018/9/9
     * @Param [column]
     **/
    @RequestMapping(value = "/modify", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<ResultMessageStruct> modifyColumn(@RequestBody AdvertisementColumn column) throws Exception {
        return () -> advertisementColumnService.modifyColumn(column);
    }

    /**
     * @return com.platform.common.domain.result.ResultMessageStruct
     * @author chenfangzhou
     * @Description modifySortNum 增加分类排序
     * @Date 9:48 2018/6/8
     * @Param [map]
     **/
    @RequestMapping(value = "/modifysortnum", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<ResultMessageStruct> modifySortNum(@RequestBody Map<String, Object> map) throws Exception {
        return () -> advertisementColumnService.modifySortNum(map);
    }

    /**
     * @return
     * @author zzx
     * @Description getChildren  获取分类父类下所有得子类
     **/
    @RequestMapping(value = "/getChildren", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<List<AdvertisementColumn>> getChildren(@RequestBody AdvertisementColumn column) throws Exception {
        return () -> advertisementColumnService.getChildren(column);
    }

    /**
     * @return
     * @author zzx
     * @Description getChildren  获取一条分类信息
     **/
    @RequestMapping(value = "/get", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<AdvertisementColumn> getColumn(@RequestBody AdvertisementColumn column) throws Exception {
        return () -> advertisementColumnService.getColumn(column);
    }

    /**
     * @throws Exception
     * @author chenfangzhou
     * @Description 根据分类id获取该分类的最顶级分类对象
     */
    @RequestMapping(value = "/getTopParentColumn", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public List<AdvertisementColumn> getTopParentColumn(@RequestBody AdvertisementColumn column) throws Exception {
        return advertisementColumnService.getTopParentColumn(column);
    }


    /**
     * @return
     * @author chenfangzhou
     * @Description 根据分类名称获取一条分类
     **/
    @RequestMapping(value = "/getColumnList", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<ResultDataStruct<List<AdvertisementColumn>>> getColumnList(@RequestBody AdvertisementColumn column) throws Exception {
        return () -> advertisementColumnService.getColumnList(column);
    }


    /**
     * @return
     * @author chenfangzhou
     * @Description 获取该站点下所有的分类数据
     **/
    @RequestMapping(value = "/getAllColumnList", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<ResultDataStruct<List<AdvertisementColumn>>> getAllColumnList(@RequestBody AdvertisementColumn column) throws Exception {
        return () -> advertisementColumnService.getAllColumnList(column);
    }

    @RequestMapping(value = "/getlisttreebykeyword", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<List<AdvertisementColumnTree>> getColumnTreeListByKeyword(@RequestBody AdvertisementColumn column) throws Exception {
        return () -> advertisementColumnService.getColumnTreeListByKeyword(column);
    }


}
